#include "stuff.h"

#ifndef QUAD
#define QUAD

class Quad
{
	private:
		Vector vertices[4];
		Vector normal;
		Vector color;

	public:
		/// default constructor

		Quad() {};
	
		/// construct quad from four vertices

		Quad::Quad(Vector vertex1, Vector vertex2, Vector vertex3, Vector vertex4, Vector color)
		{
			this->vertices[0] = vertex1;
			this->vertices[1] = vertex2;
			this->vertices[2] = vertex3;
			this->vertices[3] = vertex4;

			this->color = color;

			Vector u = vertices[1] - vertices[0];
			Vector v = vertices[3] - vertices[0];
			this->normal = (u.cross(v)).normalize();
		}

		void setColor(Vector color)
		{
			this->color = color;
		}

		Vector getColor()
		{
			return color;
		}
		
		Vector getNormal()
		{
			return normal;
		}

		/*
		void translate(Vector vector);
		GLfloat Quad::distance(Vector p);
	
		bool Quad::frontBack(Vector p);
		bool Quad::intersects(Line l, Vector* r);

		Vector insectPlane(Line l);
		*/

		void draw()
		{
			glColor3f(color.x, color.y, color.z);

			glBegin(GL_QUADS);
				glNormal3f(normal.x, normal.y, normal.z);
				glVertex3f(vertices[0].x, vertices[0].y, vertices[0].z);
				glVertex3f(vertices[1].x, vertices[1].y, vertices[1].z);
				glVertex3f(vertices[2].x, vertices[2].y, vertices[2].z);
				glVertex3f(vertices[3].x, vertices[3].y, vertices[3].z);
			glEnd();

			/*if(drawNormals)
			{
				glColor3f(GREEN.x, GREEN.y, GREEN.z);
				glBegin(GL_LINES);
					glVertex3f(vertices[0].x, vertices[0].y, vertices[0].z);
					Vector ne = vertices[0] + normal;
					glVertex3f(ne.x, ne.y, ne.z);
				glEnd();
			}*/
		}
};

#endif